package com.wantup.springboot.boot.task;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
  * @author:  zhaoluowei
  * @date :   2018/11/7 10:16
  * @version  1.0
  */
@Component
public class AsyncTask {

    /**
     *
     */
    @Async
    public void task1() throws InterruptedException {

        System.out.println("我是异步任务  我去执行 其他任务");
        System.out.println("异步任务中的 线程名 "+Thread.currentThread().getName());
        long begin = System.currentTimeMillis();
        Thread.sleep(5000L);
        long end = System.currentTimeMillis();
        System.out.println("共耗时 : "+(end - begin)/1000 );
    }


}
